﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ConfigList.aspx.cs" Inherits="background.Manager.Config.SiteConfig.ConfigList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../../Styles/index.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-1.8.2.min.js"></script>
    <script src="../../Scripts/layer/layer.js"></script>

    <script type="text/javascript">
        function changeOrder(obj) {
            $.post("../Action/SiteConfig.ashx", { action: "changeOrder", order: $(obj).val(), id: $(obj).attr("data-id") }, function (ret) {
                if (!ret) {
                    layer.msg("排序保存失败");
                }
            })
        }
        function massDelete() {
            var d = new Array();
            $("input[name='idbox']:checked").each(function () { d.push($(this).val()); })
            if (d.length == 0) { layer.msg("请选择要删除的项"); return; }

            if (confirm("确定要删除所选项吗？")) {
                $.post("../Action/SiteConfig.ashx", { action: "delete", idList: d.join(',') }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function deletes(id) {
            if (confirm("确定要删除吗？")) {
                $.post("../Action/SiteConfig.ashx", { action: "delete", idList: id }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function checkboxAll(obj) {
            $("input[name='idbox']").attr("checked", $(obj).is(":checked"));
        }
    </script>
</head>
<body>
    <div class="top">
        <strong>系统配置管理</strong>
        <span style="float: right"><a href="javascript:history.back();">
            <img src="../../Images/bak.png" />后退</a></span>
    </div>
    <div class="main">
        <div>
            <div class="tool_search">
                <input type="button" class="sbtn" value="添加配置" onclick="window.location.href = 'AddConfig.aspx?actionType=add'" />&nbsp;&nbsp;<input type="button" class="sbtn" value="批量删除" onclick="    massDelete()" />
            </div>
            <table border="0" cellpadding="0" cellspacing="0" class="listtable">
                <tr>
                    <th class="th" style="width: 20px">
                        <input type="checkbox" onchange="checkboxAll(this)" /></th>
                    <th class="th">调用拼音</th>
                    <th class="th">属性名字</th>
                    <th class="th">编辑器</th>
                    <th class="th">文本宽高</th>
                    <th class="th" style="width:80px">分组</th>
                    <th class="th">排序</th>
                    <th class="th" style="width:150px">功能描述</th>
                    <th class="th thlast">操作</th>
                </tr>
                <%System.Data.DataTable dt= Codes.SiteConfig.getList(int.Parse(string.IsNullOrEmpty(Request["p"])?"1":Request["p"]), 10); %>
                <% int j=1; foreach(System.Data.DataRow dr in dt.Rows) {%>
                <tr <%=j%2==0?"class='tr2'":"" %>>
                    <td class="td">
                        <input type="checkbox" name="idbox" value="<%=dr["id"] %>" /></td>
                    <td class="td"><%=dr["pyName"] %></td>
                    <td class="td"><%=dr["title"] %></td>
                    <td class="td"><%=dr["inputType"] %></td>
                    <td class="td"><%=dr["input_w_h"] %></td>
                    <td class="td"><%=dr["group"] %></td>
                    <td class="td">
                        <input type="text" class="text" style="width:80px" value="<%=dr["order"] %>" data-id="<%=dr["ID"] %>" onchange="changeOrder(this)" /></td>
                    <td class="td">
                        <textarea readonly="readonly" class="text" style="margin-top:12px;"><%=dr["desc"] %></textarea></td>
                    <td class="td tdlast txtcenter">
                        <a href="AddConfig.aspx?actionType=update&id=<%=dr["id"] %>">
                            <img src="../../Images/edit.png" class="tool_edit" />编辑</a>
                        <a href="javascript:void(0);" onclick="deletes(<%=dr["id"] %>)">
                            <img src="../../Images/delete.png" class="tool_delete" />删除</a></td>
                </tr>
                <%j++;
                   } %>
            </table>
            <div class="tcdPageCode"></div>
            <script src="../../Scripts/jquery.page.js"></script>
            <script>
                $(".tcdPageCode").createPage({
                    pageCount: '<%=Math.Ceiling((double)Codes.Links.getListCount()/10)%>',
                    current: '<%=string.IsNullOrEmpty(Request["p"])?"1":Request["p"]%>',
                    backFn: function (p) {
                        window.location.href = "?p=" + p;
                    }
                });
            </script>
        </div>
    </div>
    <!--#include file='../../Include/footer.html'-->
</body>
</html>
